# Function for creating sheets with test suites v.1
# ----------------------------------------------------------------------------------
# Parameters
# output.file - name of csv output file
# prefix - prefix + number is the name of test case
# data.set - subfolder with data sets
# base.file - file with base used for collaborative filtering
# test.file - file with the set of tested pairs user item - excluded from the base
# theta.low, theta.hi, theta.step 	- lowest and highest value of theta and 
#					the density of generation
# m.low, m.high,m.step			- the same for m
# M.low, M.high,M.step			- the same for M
# v.low, v.high,v.step			- the same for v
# ----------------------------------------------------------------------------------
# Example usage
# gen.test.suite("testSuite_big.csv","run","100kcsv","u1.base.csv","u1.test.csv",
#		  0,0.45,0.05,1,5,1,5,25,2,1.8,2.2,0.2)
# ----------------------------------------------------------------------------------
#
gen.test.suite<-function(output.file,prefix,data.set,base.file,test.file
					,theta.low,theta.hi,theta.step
					,m.low,m.high,m.step
					,M.low,M.high,M.step
					,v.low,v.high,v.step)
{
	cnt<-0
	print(v.high,v.low,v.step)
	v.max<-floor((v.high-v.low)/v.step)

	result<-data.frame(character(0),character(0),character(0),character(0),numeric(0),integer(0),integer(0),numeric(0))
	colnames(result)<-c("test.id","data.set","base.file","test.file","theta","m","M","v");
	for(t in 0:floor((theta.hi-theta.low)/theta.step))
		for(m in 0:floor((m.high-m.low)/m.step))
			for(M in 0:floor((M.high-M.low)/M.step))
				for(v in 0:v.max)
				{	
					cnt<-cnt+1;
					test.id <- paste(prefix,cnt,sep=" ")
					row<-data.frame(test.id=test.id,data.set=data.set,base.file=base.file,test.file=test.file,theta=theta.low+t*theta.step,m=m.low+m*m.step,M=M.low+M*M.step,v=v.low+v*v.step)
					#colnames(row)<-c("test.id","data.set","base.file","test.file","theta","m","M","v");
					result<-rbind(result,row);
				}
	write.csv2(result,output.file,row.names=FALSE)
}


# Function for creating sheets with test suites v.2
# Instead of values high,low,step the exact set of values is given
# ----------------------------------------------------------------------------------
# Parameters
# output.file - name of csv output file
# prefix - prefix + number is the name of test case
# data.set - subfolder with data sets
# base.file - file with base used for collaborative filtering
# test.file - file with the set of tested pairs user item - excluded from the base
# theta.set,m.set,M.set,v.set - set of values of the parameters. Function will 
#				generate cartesian product of them
# ----------------------------------------------------------------------------------
gen.test.suite2<-function(output.file,prefix,data.set,base.file,test.file
					,theta.set,m.set,M.set,v.set)
{
	cnt<-0
	result<-data.frame(character(0),character(0),character(0),character(0),numeric(0),integer(0),integer(0),numeric(0))
	colnames(result)<-c("test.id","data.set","base.file","test.file","theta","m","M","v");
	for(t in theta.set)
		for(m in m.set)
			for(M in M.set)
				for(v in v.set)
				{	
					cnt<-cnt+1;
					test.id <- paste(prefix,cnt,sep=" ")
					row<-data.frame(test.id=test.id,data.set=data.set,base.file=base.file,test.file=test.file,theta=theta,m=m,M=M,v=v)
					result<-rbind(result,row);
				}
	write.csv2(result,output.file,row.names=FALSE)
}
